﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Text;
using System.IO;

/// <summary>
/// Summary description for EmailTemplateBase
/// </summary>
public class EmailTemplateBase : UserControl
{
    public EmailTemplateBase()
    {
        Tags = new Dictionary<string, string>();
    }

    public Dictionary<string, string> Tags { get; set; }

    protected string GetTagValue(string tagName)
    {
        return Tags[tagName];
    }

    protected string GetTagValueSkills(string tagName)
    {
        return Tags[tagName];
    }
    protected string GetCompanyURLTagValue(string tagName)
    {
        if (!string.IsNullOrEmpty(Tags[tagName]))
            return "Company Url: " + Tags[tagName];

        return string.Empty;
    }

    protected string GetTagValue(string tagName, string defaultValue)
    {
        string val = GetTagValue(tagName);
        return string.IsNullOrEmpty(val) ? defaultValue : val;
    }

    public string RenderTemplate()
    {
        StringBuilder sb = new StringBuilder();
        StringWriter sw = new StringWriter(sb);
        Html32TextWriter htw = new Html32TextWriter(sw);
        RenderControl(htw);

        // Get full body text
        return sb.ToString();
    }
}